﻿using AutoMapper;
using NET6.WebAPI.Entities.User;
using NET6.WebAPI.Reqs.User;
using static NET6.WebAPI.Entities.Base.BusinessBase;

namespace NET6.WebAPI.Profiles
{
    public class UserProfile : Profile
    {
        public UserProfile() 
        {
            CreateMap<Sys_User, Sys_User>(); // 新旧映射

            // 设置默认值 
            CreateMap<Sys_UserAddReq, Sys_User>()
                .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(src => DateTime.Now))
                .ForMember(dest => dest.RecordStatus, opt => opt.MapFrom(src => RecordStatusEnum.Active));

            CreateMap<Sys_UserUpdateReq, Sys_User>()
                .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => DateTime.Now));
        }
    }
}
